{extends 'admin/layout/table-main.tpl'}

{block title}管理员管理{/block}
{block smallTitle}系统内的管理员管理。{/block}

{block main}
<div class="ibox float-e-margins">
	<div class="ibox-content">
		<div class="row row-lg">
			<div class="col-sm-12">
				<!-- Example Events -->
				<div class="example-wrap">
					<h4 class="example-title">{block title}{/block}</h4>
					<div class="example">
						{*{block message}{/block}*}
						<div class="btn-group hidden-xs" id="exampleTableEventsToolbar" role="group">
							<a type="button" class="btn btn-outline btn-default" href="{route('AdminAdminEdit')}">
								<i class="glyphicon glyphicon-plus" aria-hidden="true"></i>
							</a>
							{*<button type="button" class="btn btn-outline btn-default">*}
								{*<i class="glyphicon glyphicon-trash" aria-hidden="true"></i>*}
							{*</button>*}
						</div>
						<table id="exampleTablePagination" data-toggle="table" data-mobile-responsive="true">
							<thead>
							<tr>
								{*<th data-field="state" data-checkbox="false"></th>*}
								<th data-field="id">ID</th>
								<th data-field="name">用户名</th>
								<th data-field="role">角色</th>
								<th data-field="time">创建时间</th>
								<th data-field="price">操作</th>
							</tr>
							</thead>
							<tbody>
							{foreach $data as $item}
								<tr data-id="{$item.id}" data-name="{$item.username|escape}" data-type="admin" >
									<td>{$item.id}</td>
									<td>{$item.username|escape}</td>
									<td>{join(' & ', $item.roles->lists('name'))|escape}</td>
									<td>{$item.created_at}</td>
									<td>
										<a class="btn btn-xs btn-info" href="{route('AdminAdminEdit', ['id'=>$item.id])}"><i class="fa fa-edit"></i> 编辑</a>
										<button class="btn btn-xs btn-danger {if $item.id eq 1}disabled{/if}" type="button" {if $item.id ne 1}data-role="delete"{/if}><i class="fa fa-trash-o"></i> 删除</button>
									</td>
								</tr>
							{/foreach}
							</tbody>
						</table>
						{include 'admin/layout/paginate.tpl'}
					</div>
				</div>
				<!-- End Example Events -->
			</div>
		</div>
	</div>
</div>
{/block}

{block script}
	<script>
		$(document).ready(function(){
			$('[data-role="delete"]').on('click', function(){
				var data = $(this).parents('tr').data();
				iconfirm({
					action	: '{route('AdminGlobalIndividalDeletion')}',
					body		: '确定要删除管理员 ' + data.name + ' 吗？',
					data		: data
				});
				return false;
			});
		})
	</script>
{/block}
